package hk.m4s.lr.repair.test.ui.user;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.view.View;
import android.widget.LinearLayout;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;

import framework.common.Constant;
import framework.common.baseui.UeBaseActivity;
import framework.common.zanetwork.core.ResponseCallback;
import framework.utils.SharedPreferencesUtils;
import hk.m4s.lr.repair.test.R;
import hk.m4s.lr.repair.test.model.MyOrderModel;
import hk.m4s.lr.repair.test.ui.adapter.MyEnValueOderAdapter;
import hk.m4s.lr.repair.test.views.listview.VListView;
import okhttp3.Response;

/**
 * Created by qi.wang on 2017/3/23.
 * 我要评价
 */

public class MyoderEnValueActivity extends UeBaseActivity implements VListView.IXListViewListener{
    /** x下拉列表 */
    private VListView vlist;
    private TabLayout tabLayout;
    private int pageNum = 1;
    private int pageSize = 10;
    private LinearLayout show_img;
    private MyEnValueOderAdapter myOderAdapter;
    private String state="";
    private List<MyOrderModel.ListBean> myjiangLiModelList=new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        baseSetContentView(R.layout.activity_my_envalue);
        hiddenFooter();
        showGoBackBtn();
        String title=getIntent().getStringExtra("title");
        state=getIntent().getStringExtra("state");
        setTitleText("评价中心");
        findBaseView();
        vlist.setPullLoadEnable(false);
    }
    public void findBaseView(){
        show_img=(LinearLayout)findViewById(R.id.show_img);
        vlist=(VListView) findViewById(R.id.vlist);
        vlist.setXListViewListener(this);
        vlist.setPullRefreshEnable(false);
        vlist.setPullLoadEnable(false);
        myOderAdapter=new MyEnValueOderAdapter(MyoderEnValueActivity.this,myjiangLiModelList);
        vlist.setAdapter(myOderAdapter);
        onLoad();

    }
    private void onLoad() {
        vlist.stopRefresh();
        vlist.stopLoadMore();
        Date data = new Date(System.currentTimeMillis());
        vlist.setRefreshTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss",
                Locale.CHINA).format(data));
    }

    @Override
    public void onRefresh() {
        // TODO Auto-generated method stub
       // getData("1");
        vlist.setPullLoadEnable(false);
        pageNum=1;
    }

    @Override
    protected void onResume() {
        super.onResume();
       // getData("1");
        //findOrderListByUser();
    }

    @Override
    public void onLoadMore() {
        // TODO Auto-generated method stub
        vlist.setPullRefreshEnable(false);
        pageNum++;
       // getData("2");
    }

//    public void findOrderListByUser() {
//        Map<String, Object> parmas = new HashMap<>();
//        parmas.put("device_type", Constant.device_type);
//        parmas.put("token", SharedPreferencesUtils.getSharedPreferences(Constant.token, ""));
//        parmas.put("userId", SharedPreferencesUtils.getSharedPreferences(Constant.userId, ""));
//        parmas.put("status", state);
//        MyService.findOrderListByUser(MyoderEnValueActivity.this, parmas, new ResponseCallback<MyOrderModel>() {
//            @Override
//            public void onSuccess(MyOrderModel model) {
//                myjiangLiModelList.clear();
//                if (model.getList() != null) {
//                    show_img.setVisibility(View.GONE);
//                    myjiangLiModelList.addAll(model.getList());
//                }else{
//                    show_img.setVisibility(View.VISIBLE);
//                }
//                myOderAdapter.notifyDataSetChanged();
//
//            }
//
//            @Override
//            public void onError(Response response, int errorCode, String errorMsg, Exception e) {
//
//            }
//        });
//    }
}
